package cn.bdqn.veh.controller;

import cn.bdqn.model.PageBean;
import cn.bdqn.veh.model.Driver;
import cn.bdqn.veh.service.DriverService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author gurilla
 * @create 2019-08-18 11:13
 */
@Controller
@RequestMapping("/veh/driver")
public class DriverController {

    @Resource
    private DriverService driverService;

   @RequiresPermissions("veh:driver:page")
    @GetMapping
    public String topage(){
        return "/veh/driver";
    }

    @RequiresPermissions("veh:driver:list")
    @PostMapping("list")
    @ResponseBody
    public Object list(PageBean pageBean, String cname, String phone, String vidcard, String idcard){
        return driverService.list(pageBean, cname,phone,vidcard,idcard);
    }

    @RequiresPermissions("veh:driver:add")
    @PostMapping("add")
    @ResponseBody
    public Object add(Driver driver){
        return driverService.save(driver);
    }

    @RequiresPermissions("veh:driver:save")
    @PostMapping("save")
    @ResponseBody
    public Object save(Driver driver){
        return driverService.save(driver);
    }

    @RequiresPermissions("veh:driver:getAll")
    @GetMapping("getAll")
    @ResponseBody
    public Object getAll(){
        return driverService.getAll().getData();
    }

    @RequiresPermissions("veh:driver:auth")
    @PostMapping("auth")
    @ResponseBody
    public Object auth(Integer id){
        return driverService.auth(id);
    }
}
